home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / strings.swg / 0108_Fast Char Deletion.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-05-26  |  1.0 KB  |  39 lines

  1. {
  2. From: <hartkamp@mail.rz.uni-duesseldorf.de>
  3. Might be that FUNCTION CREMOVE is of interest for anyone.
  4. }
  5. FUNCTION CRemove(INP, Del : STRING) : STRING;
  6. VAR DeleteChar : SET OF CHAR;
  7.     Bytes      : ARRAY[0..31] OF BYTE ABSOLUTE DeleteChar;
  8.     BytePos    : BYTE;
  9.     BitShift   : BYTE;
  10.     DelChar    : CHAR;
  11.     i          : BYTE;
  12.     S          : STRING;
  13. BEGIN
  14.   FillChar(Bytes, SizeOf(Bytes), #0);
  15.   FOR i := 1 TO BYTE(Del[0]) DO BEGIN
  16.     DelChar := Del[i];
  17.     BytePos := BYTE(DelChar) DIV 8;
  18.     BitShift:= BYTE(DelChar) MOD 8;
  19.     Bytes[BytePos] := Bytes[BitShift] OR (1 SHL BitShift);
  20.   END;
  21.   S := '';
  22.   FOR i := 1 TO BYTE(Inp[0]) DO
  23.     IF NOT (Inp[i] IN DeleteChar) THEN S := S + Inp[i];
  24.   CRemove := S;
  25. END;
  26.  
  27. VAR S : STRING;
  28.  
  29. BEGIN
  30.   S := '══T??$h$ßßßi═ß????s$ %i%s? ???═a% ?T═e%st.???ßßß%ß.%ßßßß.';
  31.   Writeln('the test string: ');
  32.   Writeln(S);
  33.   Write('press <RETURN>'); Readln;
  34.   Writeln('the test string with cremove: ');
  35.   writeln(CREMOVE(S, '%$═?ß'));
  36.   Writeln('Ok...');
  37. END.
  38.  
  39.